package com.jtpay.textpay.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.jtpay.textpay.PayBean;
import com.jtpay.textpay.R;

import java.util.List;

public class MyAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private List<PayBean> mDatas;

    public MyAdapter(Context context, List<PayBean> datas) {
        mInflater = LayoutInflater.from(context);
        mDatas = datas;
    }

    @Override
    public int getCount() {
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.itme_listview, parent, false); //加载布局
            holder = new ViewHolder();
            holder.appidTv = convertView.findViewById(R.id.appidTv);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        PayBean bean = mDatas.get(position);
        holder.appidTv.setText(bean.getAppid());
        return convertView;
    }

    private class ViewHolder {
        TextView appidTv;
    }
}
